const axios = require('axios');
const MpWxConfig = require('./mp-weixin-config');
/**
 * @param {Object} code 
 * 获取 OPENID
 */
async function exOpenId(code){
	const url = `https://api.weixin.qq.com/sns/jscode2session?appid=${MpWxConfig.appId}&secret=${MpWxConfig.appSecret}&js_code=${code}&grant_type=authorization_code`;
	
	let res = await axios.get(url);
	
	return res.data;
}

module.exports = {
	exOpenId,
	getOpenId:exOpenId
}
